<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/resources/template/template.xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>
            <p:panel header="Manage Shifts" >
                <h:panelGrid id ="gpVeda" columns="4" styleClass="alignTop" >

                    <h:panelGrid id="gpSelect" columns="1"  >
                        <h:panelGrid columns="2">
                            <h:outputText  value="Roster" ></h:outputText>
                            <p:selectOneMenu id='roster' value="#{shiftController.currentRoster}" >
                                <f:selectItem itemLabel="Select Roster"/>
                                <f:selectItems value="#{rosterController.items}" var="d" itemLabel="#{d.name}" itemValue="#{d}"/>
                                <f:ajax event="change" execute="@this" render="gpSelectText gpDetail" listener="#{shiftController.createShiftList()}" />
                            </p:selectOneMenu>
                        </h:panelGrid>
                        <p:panel >
                            <h:panelGrid id="gpSelectText" >
                                <p:selectOneListbox  id="lstSelect"   value="#{shiftController.current}" style="min-width: 223px;max-height: 400px;">
                                    <f:selectItems  value="#{shiftController.shiftList}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                    <p:ajax update="gpDetail" process="@this" >
                                    </p:ajax>
                                </p:selectOneListbox>                               
                            </h:panelGrid>
                            <h:panelGrid id="gpSelectButtons" columns="3"  >
                                <p:commandButton id="btnAdd" ajax="false" value="Add" action="#{shiftController.prepareAdd()}" styleClass="buttons" onclick="onSubmitButton();" >
                                </p:commandButton>
                                <p:commandButton id="btnDelete" ajax="false" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                            return false;" action="#{shiftController.delete()}"  value="Delete"  >
                                </p:commandButton>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid  >



                    <p:panel id="gpDetail">
                        <f:facet name="header">
                            <h:outputLabel value="Shift Detail &nbsp;"/>
                            <p:commandButton ajax="false" value="Save"  
                                             action="#{shiftController.saveSelected}"  
                                             onclick="onSubmitButton();"/>
                            <p:commandButton ajax="false" value="Print" style="float: right;" >
                                <p:printer target="panelPrint" ></p:printer>
                            </p:commandButton>
                        </f:facet>
                        <h:panelGrid id="gpDetailText" columns="2">

                            <h:outputText  value="Name" ></h:outputText>
                            <p:inputText autocomplete="off"  value="#{shiftController.current.name}"  />
                            <h:outputText  value="Day Type" ></h:outputText>
                            <p:selectOneMenu   value="#{shiftController.current.dayType}">                               
                                <f:selectItems value="#{enumController.dayTypeForShift}"/>
                                <f:ajax execute="@this roster" render="start" event="change"/>
                            </p:selectOneMenu>
                            <h:outputLabel value="Shift Order" rendered="false"/>
                            <p:inputText autocomplete="off" value="#{shiftController.current.shiftOrder}" rendered="false"/>
                            <p:outputLabel value="Starting Time"/>
                            <p:calendar id='start'  value="#{shiftController.current.startingTime}" navigator="true" pattern="hh:mm:ss a" timeOnly="true">                            
                            </p:calendar>  

                            <p:outputLabel value="End Time"/>                        
                            <p:calendar  value="#{shiftController.current.endingTime}" navigator="true" pattern="hh:mm:ss a" timeOnly="true">                            
                            </p:calendar>  

                            <p:outputLabel value="Previous Shift"/>
                            <p:autoComplete value="#{shiftController.current.previousShift}"
                                            forceSelection="true"
                                            completeMethod="#{shiftController.completeShift}"
                                            var="mys" 
                                            itemLabel="#{mys.name}" 
                                            itemValue="#{mys}">                                  
                            </p:autoComplete>

                            <p:outputLabel value="Next Shift"/>
                            <p:autoComplete value="#{shiftController.current.nextShift}"
                                            forceSelection="true"
                                            completeMethod="#{shiftController.completeShift}"
                                            var="mys" 
                                            itemLabel="#{mys.name}" 
                                            itemValue="#{mys}">                                  
                            </p:autoComplete>
                            <h:outputLabel value="Leave Hour Full"/>
                            <h:inputText value="#{shiftController.current.leaveHourFull}"/>
                            <h:outputLabel value="Leave Hour Half"/>
                            <h:inputText value="#{shiftController.current.leaveHourHalf}"/>
                            <h:outputLabel value="Duration Minute"/>
                            <h:outputLabel value="#{shiftController.current.durationMin}"/>

                            <p:outputLabel value="First Shift"/>
                            <p:selectBooleanCheckbox value="#{shiftController.current.firstShift}" />
                            <p:outputLabel value="Last Shift"/>
                            <p:selectBooleanCheckbox value="#{shiftController.current.lastShift}" />
                            <p:outputLabel value="Half Shift"/>
                            <p:selectBooleanCheckbox value="#{shiftController.current.halfShift}" />                           
                            <p:outputLabel value="Hide Shift"/>
                            <p:selectBooleanCheckbox value="#{shiftController.current.hideShift}" />


                            <p:outputLabel value="This Shift Id"/>
                            <p:outputLabel value="#{shiftController.current.id}"/>

                            <p:outputLabel value="Previous Shift Id"/>
                            <p:outputLabel value="#{shiftController.current.previousShift.id}"/>

                            <p:outputLabel value="Next Shift Id"/>
                            <p:outputLabel value="#{shiftController.current.nextShift.id}"/>

                        </h:panelGrid>
                    </p:panel>


                </h:panelGrid>
                <p:panel id="panelPrint" styleClass="printOnly">
                    <f:facet name="header">
                        <h:outputLabel value="Shift Detail"/>                        
                    </f:facet>
                    <h:panelGrid id="gpDetailTextPrint" columns="3">

                        <h:outputText  value="Name" ></h:outputText>
                        <h:outputLabel value=":"/>
                        <h:outputText value="#{shiftController.current.name}"/>

                        <h:outputText  value="Day Type" ></h:outputText>
                        <h:outputLabel value=":"/>
                        <h:outputText  value="#{shiftController.current.dayType}"/>

                        <h:outputLabel value="Shift Order" rendered="false"/>
                        <h:outputLabel value=":" rendered="false"/>
                        <h:outputLabel value="#{shiftController.current.shiftOrder}" rendered="false"/>

                        <p:outputLabel value="Starting Time"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.startingTime}">
                            <f:convertDateTime pattern="hh:mm:ss a"/>
                        </h:outputLabel>  

                        <p:outputLabel value="End Time"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.endingTime}">
                            <f:convertDateTime pattern="hh:mm:ss a"/>
                        </h:outputLabel>  

                        <p:outputLabel value="Previous Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.previousShift}"/>

                        <p:outputLabel value="Next Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.nextShift}"/>

                        <h:outputLabel value="Leave Hour Full"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.leaveHourFull}"/>

                        <h:outputLabel value="Leave Hour Half"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.leaveHourHalf}"/>

                        <h:outputLabel value="Duration Minute"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.durationMin}"/>

                        <p:outputLabel value="First Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.firstShift ? 'Yes':'No'}" />

                        <p:outputLabel value="Last Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.lastShift ? 'Yes':'No'}" />

                        <p:outputLabel value="Half Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.halfShift ? 'Yes':'No'}" />

                        <p:outputLabel value="Hide Shift"/>
                        <h:outputLabel value=":"/>
                        <h:outputLabel value="#{shiftController.current.hideShift ? 'Yes':'No'}" />


                        <p:outputLabel value="This Shift Id"/>
                        <h:outputLabel value=":"/>
                        <p:outputLabel value="#{shiftController.current.id}"/>

                        <p:outputLabel value="Previous Shift Id"/>
                        <h:outputLabel value=":"/>
                        <p:outputLabel value="#{shiftController.current.previousShift.id}"/>

                        <p:outputLabel value="Next Shift Id"/>
                        <h:outputLabel value=":"/>
                        <p:outputLabel value="#{shiftController.current.nextShift.id}"/>

                        <p:outputLabel value="Creater"/>
                        <h:outputLabel value=":"/>
                        <p:outputLabel value="#{shiftController.current.creater.webUserPerson.name}"/>

                        <p:outputLabel value="Created At"/>
                        <h:outputLabel value=":"/>
                        <p:outputLabel value="#{shiftController.current.createdAt}">
                            <f:convertDateTime pattern="hh:mm:ss a"/>
                        </p:outputLabel>

                    </h:panelGrid>

                </p:panel>

            </p:panel>


        </h:form>
    </ui:define>


</ui:composition>
